package org.mx.notify.config;

import org.mx.notify.processor.NotifyServerWebSocket;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;

/**
 * 推送服务器配置类
 * 
 * @author john.peng
 *
 */
public class NotifyServerConfig {
	/**
	 * 从配置文件中创建推送服务器配置信息
	 * 
	 * @return 配置信息
	 */
	@Bean("notifyServerConfigBean")
	public NotifyServerConfigBean notifyServerConfigBean() {
		return new NotifyServerConfigBean();
	}

	/**
	 * 创建推送服务器WebSocket
	 * 
	 * @param context    Spring IoC容器
	 * @param configBean 推送服务器配置信息
	 * @return 推送服务器WebSocket
	 */
	@Bean(name = "notifyServerWebSocket", initMethod = "init", destroyMethod = "destroy")
	public NotifyServerWebSocket notifyServerWebSocket(ApplicationContext context, NotifyServerConfigBean configBean) {
		return new NotifyServerWebSocket(context, configBean);
	}
}
